import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LoginServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        String username = req.getParameter("username");
        String pwd = req.getParameter("password");
        String[] hobby = req.getParameterValues("hobby");

        System.out.println(username+":"+pwd+" "+hobby);
//        resp.sendRedirect();
//        servletContext.getRequestDispatcher("/get").forward(req,resp);通过servlet转发



        //介绍第三种方式，请求转发
        req.getRequestDispatcher("/success.jsp").forward(req,resp);
        //转发的时候，路径直接写最后的页面即可，不需要带上项目名




    }
}
